# Exercise 3.3
# Write a function named right_justify that takes a string named s 
# as a parameter and prints the
# string with enough leading spaces so that the last letter of the 
# string is in column 70 of the display
print '** CHAPTER 3 exercises **'

def right_justify(s):
    line = 70
    l = len(s)
    space = 70-l
    print ' '*space,
    print s

right_justify('people')
right_justify('are')
right_justify('oddities')

def do_twice(f):
    f()
    f()
    
def print_holmes():
    print 'holmes'

do_twice(print_holmes)

def print_bars():
    print "|         |         |"

def print_tops():
    print "+ - - - - + - - - - +"

def do_4(f):
    f()
    f()
    f()
    f()
          
def print_boxes():
    print_tops()
    do_4(print_bars)
    print_tops()
    do_4(print_bars)
    print_tops()

print_boxes()  

import time
def f():
    st = time.time()
    x = 0
    for i in range(90**3):
        x+=i
        if x%2:
            x*=3
        else: x/=45
    ed = time.time()
    print ed - st

def twice(f):
    print 'once\n\t',
    f()
    print 'twice\n\t',
    f()
    
twice(f)